<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象的枚举</title>
</head>
<body>
<script>
    // var arr = [1,2,3,4,5,6,7,8,9];
    // for(var i=0; i<arr.length; i++){
    //     console.log(arr[i]);
    // }

/*
    var obj = {
        name : "hanyun",
        age : 18,
        sex : "male",
        height : 180
    };
    for(var prop in obj){
        console.log(obj.prop);//undefined   obj.prop --> obj['prop']
        console.log(obj[prop]);//遍历属性
    }
*/

/*
    var obj1 = {
        name : "hanyun",
        age : 18,
        sex : "male",
        height : 180,
        __proto__ : {
            lastName : "wei"
        }
    };
    for(var prop in obj1){
        //console.log(obj1[prop]);//hanyun 18 male 180 --wei--
        //访问到了原型 __proto__ 属性
        //怎么不让它访问到原型属性呢？   //用 hasOwnProperty
        if(obj1.hasOwnProperty(prop)){//判断prop是不是obj1的属性和方法
            console.log(obj1[prop]);//hanyun 18 male 180

        }
    }
*/

    var obj1 = {
        name : "hanyun",
        age : 18,
        sex : "male",
        height : 180,
        __proto__ : {
            lastName : "wei"
        }
    };
    if("name" in obj1){
        console.log(obj1.name);//hanyun
    }
    if("lastName" in obj1){
        console.log(obj1.lastName);//wei
    }

    function Person(){
        //...
    }
    var person = new Person();
    var a = person instanceof Person;
    //console.log(a);//true
    console.log(person instanceof Object);//true  why?
    console.log([] instanceof Array);//true  why?
    console.log([] instanceof Object);//true  why?
    //看  A对象  的原型链上  有没有  B 的原型
</script>
</body>
</html>
